package com.infusionesuci2;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.app.Activity;

public class AdaptadorSpinner extends ArrayAdapter<String> {
	
	private final Activity activity;
	String [] spinnerValues;

	public AdaptadorSpinner(Activity activity, int txtViewResourceId, String[] objects) {
        super(activity.getApplicationContext(), txtViewResourceId, objects);
        this.activity=activity;
        this.spinnerValues=objects;
    }

    @Override
    public View getDropDownView(int position, View cnvtView, ViewGroup prnt) {
        return getCustomView(position, cnvtView, prnt);
    }
    @Override
    public View getView(int pos, View cnvtView, ViewGroup prnt) {
        return getCustomView(pos, cnvtView, prnt);
    }
    
    public View getCustomView(int position, View convertView,
            ViewGroup parent) {
        LayoutInflater inflater = this.activity.getLayoutInflater();
        View mySpinner = inflater.inflate(R.layout.custom_spinner, parent,
                false);
        TextView main_text = (TextView) mySpinner
                .findViewById(R.id.text_main_seen);
        main_text.setText(spinnerValues[position]);

        return mySpinner;
    }
}
